package de.koller.transit.render;

import de.koller.aframe.plain.Sprite;
import de.koller.aframe.util.resource.SpriteTileGen;
import de.koller.transit.TNode;
import de.koller.transit.engine.brush.Brush;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;

public class TRender extends TNode {
	
	public SpriteTileGen textures;
	private boolean brushSetup = false;
	
	@Override
	protected void init() {
		super.init();
		
		textures = SpriteTileGen.create( "gameData/transit/texture.png", "gameData/transit/texture.config",
				troot.display.getGraphicsConfiguration() );
	}
	
	public void renderThis( Graphics2D g, int elapsedTime ) {
		if( !brushSetup ) {
			GraphicsConfiguration gc = troot.display.getGraphicsConfiguration();
			Sprite template = textures.getSprite( "brush" );
			troot.engine.brushContainer.playerA.render.setup( gc, template );
			troot.engine.brushContainer.playerB.render.setup( gc, template );
			brushSetup = true;
		}
		
		Brush ba = troot.engine.brushContainer.playerA.brush;
		troot.engine.paper.renderThis( g, ba.getClip() );
		
		Brush bb = troot.engine.brushContainer.playerB.brush;
		troot.engine.paper.renderThis( g, bb.getClip() );
		
		troot.engine.brushContainer.playerA.renderBrush( g, elapsedTime );
		troot.engine.brushContainer.playerB.renderBrush( g, elapsedTime );
	}
	
}
